package com.io;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * 编写程序实现图片的拷贝
 *
 * @author: Jovi
 * @createTime: 2017-06-20 14:04
 **/
public class ReadImage {

    public static void main(String[] args) {
        FileInputStream fis = null;
        FileOutputStream fos = null;
        try {
            fis = new FileInputStream("/Users/Jovi/Downloads/icon.jpg");
            fos = new FileOutputStream("/Users/Jovi/Downloads/1icon.jpg");
            int count;
            byte[] temp = new byte[100];
            try {
                while ((count = fis.read(temp)) > 0) {
                    fos.write(temp, 0, count);
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
            System.out.println("copy success!");

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }finally {
            try {
                fis.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
            try {
                fos.close();
            } catch (IOException e) {
                e.printStackTrace();
            }

        }
    }
}
